package day02;

/**
 *变量/数据都要存储在内存中，内存是有大小的，
 * 数据到底占用多大的内存，是有它的数据类型控制的
 * 字面量/直接量：
 * 整数直接量：直接写出来的整数
 */
public class DataTypeDemo {
    public static void main(String[] args) {
        /*
        //1)int：整型，4 个字节，-21个多亿到21个多亿
        int a = 250;
        //int b = 10000000000;//编译错误，100亿默认为int类型，但超出范围了
        //int c = 25.678;//编译错误，整型变量中只能装整数

        System.out.println(5/2);//2
        System.out.println(2/5);//0
        System.out.println(5.0/2);//2.5

        int d = 2147483647;//int的最大值
        d = d + 1;
        System.out.println(d);//+1   -2147483648  发生了溢出

         */
        /*
        //2)
        long a  =25L;
        //long b = 10000000000;
        long c = 10000000000L;
        long d  = 365L*24*60*60*1000;
        System.out.println(d);

        long e = 1000000000*2*10L;
        System.out.println(e);
        long f = 100000000*3*10;
        System.out.println(f);
        long g = 100000000L*3*10;
        System.out.println(g);

        //3)浮点型
        double a1 = 25.678;
        double b1 = 25.678F;
        double c1 = 3.0,d1 = 2.9;
        System.out.println(c1-d1);

         */
        //4）boolean
        /*
        boolean a = true;
        boolean b = false;
        //boolean c = 25.6;

         */
        /*
        char c1 = '女';
        char c2 = 'f';
        char c3 = '6';
        char c4 = ' ';
        //char c5 = 女;
        //char c6 = '';
        //char c7 = '10';

        char c8 = 65;//0到65535之间
        System.out.println(c8);

        char c9 = '\\';
        System.out.println(c9);

         */
        //类型间的转换：
        int a = 5;
        long b = a;//自动/隐式类型转换
        int c = (int)b;//强制类型转换

        long d = 5;//自动类型转换
        double e = 5;//自动类型转换
        System.out.println(e);//5.0

        long f = 10000000000L;
        int g = (int)f;//发生溢出
        System.out.println(g);//1410065408

        double h = 25.678;
        int i = (int)h;//强制类型转换,丢失精度
        System.out.println(i);//25

        byte b1 = 5;
        byte b2 = 6;
        byte b3 = (byte) (b1+b2);
        System.out.println(b3);
        System.out.println('2');

        int a1 = '我';
        System.out.println(a);
        char b6 = 65;
        System.out.println(b);

    }
}
